package com.wasu.entity.live;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>------------------------------------------------------
 * <p>Copyright (C) 2020 wasu company, All rights reserved.
 * <p>------------------------------------------------------
 * <p> 频道分组信息
 * <p>
 *
 * @author Created by zhangmz
 * @date on 2023/8/1
 */
public class WasuBouInfor implements Parcelable {

    /**
     * 频道组ID
     */
    private String bId;
    /**
     * 频道组名称
     */
    private String bName;
    /**
     * 频道组英文名称
     */
    private String bEnName;
    /**
     * 频道组其他名称(JSON)
     */
    private String bOtrName;
    /**
     * 分组下频道数量
     */
    private int bNumbers;
    /**
     * 分组首频道chId
     */
    private String firstChId;
    /**
     * 分组排序
     */
    private int sortBy;
    /**
     * 频道列表
     */
    private List<WasuChInfor> chList = new ArrayList<>();

    public WasuBouInfor(){

    }

    public WasuBouInfor(String bId, String bName, String bEnName, String bOtrName, int bNumbers, String firstChId, int sortBy, List<WasuChInfor> chList) {
        this.bId = bId;
        this.bName = bName;
        this.bEnName = bEnName;
        this.bOtrName = bOtrName;
        this.bNumbers = bNumbers;
        this.firstChId = firstChId;
        this.sortBy = sortBy;
        this.chList = chList;
    }

    protected WasuBouInfor(Parcel in) {
        bId = in.readString();
        bName = in.readString();
        bEnName = in.readString();
        bOtrName = in.readString();
        bNumbers = in.readInt();
        firstChId = in.readString();
        sortBy = in.readInt();
        chList = in.createTypedArrayList(WasuChInfor.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(bId);
        dest.writeString(bName);
        dest.writeString(bEnName);
        dest.writeString(bOtrName);
        dest.writeInt(bNumbers);
        dest.writeString(firstChId);
        dest.writeInt(sortBy);
        dest.writeTypedList(chList);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<WasuBouInfor> CREATOR = new Creator<WasuBouInfor>() {
        @Override
        public WasuBouInfor createFromParcel(Parcel in) {
            return new WasuBouInfor(in);
        }

        @Override
        public WasuBouInfor[] newArray(int size) {
            return new WasuBouInfor[size];
        }
    };

    public String getbId() {
        return bId;
    }

    public void setbId(String bId) {
        this.bId = bId;
    }

    public String getbName() {
        return bName;
    }

    public void setbName(String bName) {
        this.bName = bName;
    }

    public String getbEnName() {
        return bEnName;
    }

    public void setbEnName(String bEnName) {
        this.bEnName = bEnName;
    }

    public String getbOtrName() {
        return bOtrName;
    }

    public void setbOtrName(String bOtrName) {
        this.bOtrName = bOtrName;
    }

    public int getbNumbers() {
        return bNumbers;
    }

    public void setbNumbers(int bNumbers) {
        this.bNumbers = bNumbers;
    }

    public String getFirstChId() {
        return firstChId;
    }

    public void setFirstChId(String firstChId) {
        this.firstChId = firstChId;
    }

    public int getSortBy() {
        return sortBy;
    }

    public void setSortBy(int sortBy) {
        this.sortBy = sortBy;
    }

    public List<WasuChInfor> getChList() {
        return chList;
    }

    public void setChList(List<WasuChInfor> chList) {
        this.chList = chList;
    }

    public void addWasuChInfor(WasuChInfor chi) {
        int index = 0;
        for (WasuChInfor temp: chList) {
            if (chi.getChNo() < temp.getChNo()) {
                chList.add(index, chi);
                return;
            }
            index++;
        }
        chList.add(chi);
    }

    @Override
    public String toString() {
        return "WasuBouInfor{" +
                "bId='" + bId + '\'' +
                ", bName='" + bName + '\'' +
                ", bEnName='" + bEnName + '\'' +
                ", bOtrName='" + bOtrName + '\'' +
                ", bNumbers=" + bNumbers +
                ", firstChId='" + firstChId + '\'' +
                ", sortBy=" + sortBy +
                ", chList=" + chList +
                '}';
    }
}
